// LensFlare.cpp: implementation of the LensFlare class.
//
//////////////////////////////////////////////////////////////////////

#include "LensFlare.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

LensFlare::LensFlare(ssgTransform* sunTransform)
{
	this->lensFlare = new ssgaLensFlare;
	sunTransform->addKid(this->lensFlare);
	this->lensFlareTransform = sunTransform;
	this->enabled = 1;
}

LensFlare::~LensFlare()
{

}

void LensFlare::update(Sky *sk)
{
	if(this->enabled)
	{
	sgCoord lfpos;
	sk->getSunPosition(&lfpos);
	this->lensFlareTransform->setTransform(lfpos.xyz);	
	}
}

void LensFlare::enable()
{
	// if it was NOT enabled...
	if(!this->enabled)
		{
		// enable...
		this->enabled = 1;
		// tell the scenegraph to display it
		this->lensFlare->setTraversalMaskBits(SSGTRAV_CULL);
		}
}

void LensFlare::disable()
{
	// if it was enabled...
	if(this->enabled)
		{
		// disable...
		this->enabled = 0;
		// don't show the lens flare
		this->lensFlare->clrTraversalMaskBits(SSGTRAV_CULL);
		}
}
